<?php

namespace App\Http\Controllers\Ad;

use App\Http\Controllers\BaseController;
use Illuminate\Support\Facades\DB;

class TotalController extends BaseController
{
    public function index()
    {
        $online_ad_count = DB::table('ads')->whereIn('status',[2,3,4])->count('id');
        $play_ad_count = DB::table('ads')->where('status',3)->count('id');
        $ad_amount = DB::table('ads')->whereIn('status',[2,3,4])->sum('amount');
        $consume_amount = DB::table('ads')->where('status',4)->sum('amount');
        $order_count = DB::table('ads')
                    ->whereIn('status',[2,3])
                    ->where('order_user_id','>',0)
                    ->count('amount');
        return $this->success([
            'online_ad_count' => $online_ad_count,
            'play_ad_count' => $play_ad_count,
            'ad_amount' => $ad_amount,
            'consume_amount' => $consume_amount,
            'order_count' => $order_count,
        ]);
    }
}
